package com.dll.pybig.dao;

import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.dll.pybig.pojo.StuScore;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultType;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

/**
 * @author jj
 */
@Repository

public interface StuScoreMapper extends BaseMapper<StuScore> {
    /**
     * 查询已逻辑删除的记录
     * @param page 分页信息
     * @param wrapper 查询选择器
     * @return 查询信息
     */
    @Select("select * from student  ${ew.customSqlSegment} and deleted = 1")

    IPage<StuScore> selectDeleted(Page<StuScore> page ,@Param(Constants.WRAPPER) Wrapper<StuScore> wrapper);

    @Select("select * from student  where stuNum = ${stuNums} and deleted = 1")
    StuScore selectOneDeleted(Long stuNums);
    @ResultType(Integer.class)
    @Update("update student set deleted = 0 where stuNum = ${stuNums} and deleted = 1")
    Integer recoverUser(Long stuNums);

    @ResultType(Integer.class)
    @Update("update student set stuName = '${stuScore.stuName}',signupTimes = ${stuScore.signupTimes}" +
            ",avgSeatNum = ${stuScore.avgSeatNum}," +
            "signUpScore = ${stuScore.signUpScore}," +
            "askScore = ${stuScore.askScore}," +
            "totalScore = ${stuScore.totalScore} ${ew.customSqlSegment} ")
    Integer UpdateUser(StuScore stuScore,@Param(Constants.WRAPPER) Wrapper<StuScore> wrapper);
}
